﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TeamMaintenance.aspx.cs" Inherits="MeetingMinutesManager.Maintenance.TeamMaintenance" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Team Maintenance</title>
    <style type="text/css">
        .style2
        {
            text-align: right;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    
        <table class="style1">
            <tr>
                <td class="style2">
                    Team:</td>
                <td>
                    <asp:TextBox ID="txtTeam" runat="server" Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Belongs To:</td>
                <td>
                    <asp:DropDownList ID="ddlParents" runat="server" 
                        DataSourceID="SqlDataSourceParents" DataTextField="Team" DataValueField="id" 
                        Width="200px">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSourceParents" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:LocalConnectionString %>" 
                        ProviderName="<%$ ConnectionStrings:LocalConnectionString.ProviderName %>" 
                        SelectCommand="select top 1 '' Team, 0 id from team union SELECT [team], [id] FROM [team] WHERE ([parent] IS NULL)">
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="Add Team" />
                </td>
                <td>
                    <asp:Button ID="btnClean" runat="server" onclick="btnClean_Click" 
                        Text="Clean" />
                </td>
            </tr>
        </table>
    </div>
    <asp:GridView ID="grvTeams" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
        DataKeyNames="id" DataSourceID="SqlDataSourceTeams" ForeColor="#333333" 
        GridLines="None">
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="team" HeaderText="team" SortExpression="team" />
            <asp:BoundField DataField="parent" HeaderText="parent" 
                SortExpression="parent" />
            <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                ReadOnly="True" SortExpression="id" />
        </Columns>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSourceTeams" runat="server" 
        ConnectionString="<%$ ConnectionStrings:LocalConnectionString %>" 
        DeleteCommand="DELETE FROM [team] WHERE [id] = ?" 
        InsertCommand="INSERT INTO [team] ([team], [parent], [id]) VALUES (?, ?, ?)" 
        ProviderName="<%$ ConnectionStrings:LocalConnectionString.ProviderName %>" 
        SelectCommand="SELECT [team], [parent], [id] FROM [team] ORDER BY [team]" 
        UpdateCommand="UPDATE [team] SET [team] = ?, [parent] = ? WHERE [id] = ?">
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="team" Type="String" />
            <asp:Parameter Name="parent" Type="Int32" />
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="team" Type="String" />
            <asp:Parameter Name="parent" Type="Int32" />
            <asp:Parameter Name="id" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
